package com.sdweizan.sdk.bytedance.bean.refund.general;

import com.alibaba.fastjson.annotation.JSONField;
import com.sdweizan.sdk.bytedance.bean.BdBaseRequest;
import com.sdweizan.sdk.bytedance.bean.payment.general.BdGeneralPageSchema;
import java.util.List;

import com.sdweizan.sdk.bytedance.constants.BdConstants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BdGeneralCreateRefundRequest implements BdBaseRequest {

  /** 开发者自定义字段，回调原样回传* */
  @JSONField(name = "cp_extra")
  private String cpExtra;

  /** 退款单的跳转的schema* */
  @JSONField(name = "order_entry_schema")
  private BdGeneralPageSchema orderEntrySchema;

  /** 抖音开平侧订单号* */
  @JSONField(name = "order_id")
  private String orderId;

  /** 商户分配退款号，保证在商户中唯一* */
  @JSONField(name = "out_refund_no")
  private String outRefundNo;

  /** 退款原因，可填多个，不超过10个* */
  @JSONField(name = "refund_reason")
  private List<RefundReason> refundReasonList;

  /*** 退款金额，单位分***/
  @JSONField(name = "refund_total_amount")
  private Long refundTotalAmount;

  @JSONField(name = "item_order_detail")
  private List<BdRefundItemOrderDetail> itemOrderDetail;

  /***商户自定义回调地址***/
  @JSONField(name = "notify_url")
  private String notifyUrl;

  /**
   * 当订单未发生任何退款时，可设置refund_all=true，refund_total_amount=订单实付金额，发起整单退款。refund_all=true时不能设置item_order_detail*
   */
  @JSONField(name = "refund_all")
  private Boolean refundAll;

  @Override
  public String requestUri() {
    return BdConstants.OPEN_HOST + "/api/trade_basic/v1/developer/refund_create";
  }

  @Data
  public static class RefundReason {

    /** 枚举类BdRefundReasonEnum * */
    private Integer code;

    /** 退款原因描述，开发者可自定义，长度<50* */
    private String text;
  }
}
